package tuiLayer;
import controlLayer.*;
import modelLayer.*;
import java.util.*;

public class StatisticUI
{   
    private SellCtr sellCtr;
    private LoanCtr loanCtr;

    public StatisticUI(){
        sellCtr = new SellCtr();
        loanCtr = new LoanCtr();
    }

    public void start(){
        mainMenuStatistic();
    }

    private void mainMenuStatistic(){
        boolean stop=false;
        while(!stop){
            int choice = writeStatisticMenu();
            switch(choice){
                case 0:
                    stop = true;
                    break;             
                case 1:
                    showStatistic();
                    break;
                default : System.out.println("Enter a valid choice");
            }
        }
    }

    private int writeStatisticMenu(){
        Scanner keyboard = new Scanner(System.in);
        System.out.println("\n*****Statistic menu*****");
        System.out.println("(0) Back");
        System.out.println("(1) Show Statistic");
        System.out.println("\nType your choice");
        int choice= keyboard.nextInt();
        return choice;
    }

    private void showStatistic(){
        int a=sellCtr.getTotalAmountSells();
        int b=loanCtr.getTotalAmountLoans();
        System.out.println("--------------------------------");
        System.out.println("Number of sales: "+sellCtr.getSellsNo());
        System.out.println("Number of loans: "+loanCtr.getLoansNo());
        System.out.println("Total money from sales: "+ a);
        System.out.println("Total money from loans: "+b);
        System.out.println("Total amount of money: "+(a+b));
        System.out.println("--------------------------------");
    }
}
